
	   
	   
	   set more off
graph drop _all

use Data/Estimation_sample.dta, clear 

	
 
	gen nexis_buildings  = ROOFME/PROOFME
		
		
			gen roofratio = ROOFME/ROOFTI
		gen roofratiobuildings = roofratio*nexis_buildings
		
		gen roofrelativeIV = (roofratio*nexis_buildings/[moduleprice])/1000

 
	* 3 quarters is nine months 

	
	gen event_time = quarter - tq(2011q1) if quarter< tq(2011q1) 	
	replace event_time = quarter- tq(2013q1) if quarter > tq(2013q1)
	replace event_time = 0 if quarter >= tq(2011q1) & quarter<=  tq(2013q1)
	
	quietly tab event_time, gen(newevents)
	
	forval i = 1(1)19 {
	
	gen eventcum`i' = (newevents`i' ==1)* cuminstall
	
	
	
	}
	
	
	
	
	
	gen high_cum = (event_time<0 )*cuminstall
	gen change_cum = (event_time ==0 )* cuminstall
	gen low_cum =( event_time >0) * cuminstall
	
	
	
	
	
	
	
	
	xi: xtivreg2 green_p high_cum change_cum low_cum  ///
	 i.quarter  [aweight =NCustomer]   ,  fe cluster(postcode)
	   
	eststo model1
	

	label variable low_cum "Low"
	label variable change_cum "Decreasing"
	label variable high_cum "High"
	
	
coefplot (model1, keep(low_cum) mcolor(gs0) ciopts(lcolor(gs0)) msymbol(o)) ///
  (model1, keep(change_cum ) mcolor(gs0) ciopts(lcolor(gso)) msymbol(o)) ///
 (model1, keep( high_cum) mcolor(gs0) ciopts(lcolor(gs0)) msymbol(o)), vertical ///
 relocate(low_cum = -1 change_cum = 0 high_cum=1 )  legend(off) xtitle("Subsidy Period") yline(0) ///
 xline(0, lcolor(gs10) lpattern(dash) lwidth(vthin)) xlabel(, labsize(large)) ylabel(, labsize(large)) ytitle(, size(large)) xtitle(, size(large))
	
	
	 	graph export Analysis/BeforeAfterpaper.png, replace

		
		graph export Analysis/BeforeAfterpaper.eps, replace
	
	
